package com.xzs.thinking.config;

import com.xzs.thinking.interceptor.MyInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * @author : Iris.Xiao
 * @date : 2017/11/17 17:14
 * @description :
 */
@Configuration
public class MyWebAppConfigurer extends WebMvcConfigurerAdapter {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
//        如果我们将/myres/* 修改为 /* 与默认的相同时，则会覆盖系统的配置，
        registry.addResourceHandler("/myres/**").addResourceLocations("classpath:/myres/");
        registry.addResourceHandler("/location/**").addResourceLocations("file:C:/Users/Dell/Desktop");
        super.addResourceHandlers(registry);
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
//      可以使用 addPathPatterns("/**")控制;
        registry.addInterceptor(new MyInterceptor());
        super.addInterceptors(registry);
    }
}
